# This is a sample Python script.
import os
import threading
import time

from common.bootstrap import Bootstrap
from common.common import BusinessInput
from watermark.heart_beat.heart_beat_manager import HeartBeatManager
from watermark.water_mark.watermark import Watermark


def un_struct_watermark():
    Bootstrap.start()
    # HeartBeatManager.start_heart_beat()
    # time.sleep(50)
    business_input = BusinessInput(user="张三", ip="127.0.0.1", api_customize_watermark_content="自定义内容",
                                   charset="UTF-8")
    source_file_path = "C:\\Users\\Spring\\Desktop\\watermark_test\\source.png"
    target_file_path = "C:\\Users\\Spring\\Desktop\\watermark_test\\target.png"
    result = Watermark.un_struct_watermark(business_input, source_file_path, target_file_path)
    if result.code == 0:
        print("水印添加成功")
    Bootstrap.stop()


def struct_watermark():
    Bootstrap.start()
    # HeartBeatManager.start_heart_beat()
    business_input = BusinessInput(user="张三", ip="127.0.0.1")
    source_file_path = "C:\\Users\\Spring\\Desktop\\watermark_test\\test.xls"
    target_file_path = "C:\\Users\\Spring\\Desktop\\watermark_test\\test-target.xls"
    result = Watermark.struct_watermark(business_input, source_file_path, target_file_path)
    if result.code == 0:
        print("水印添加成功")


def struct_watermark_open_heartbeat():
    heartbeat_thread = threading.Thread(target=HeartBeatManager.start_heart_beat)
    heartbeat_thread.start()
    time.sleep(30)
    struct_watermark()
    heartbeat_thread.join()


# Press the green button in the gutter to run the script.
# if __name__ == '__main__':
#     # struct_watermark_open_heartbeat()
#     # time.sleep(5 *60)
#     un_struct_watermark()
